--编写者：alt
--功能介绍：重定向动作的目标函数
--使用方法：直接粘贴 修改actionlist

--重定向动作的目标函数
local actionlist = {
	[ACTIONS.ATTACK] = function(inst, act, oldresult)
		local weapon = inst.components.combat ~= nil and inst.components.combat:GetWeapon() or nil
		if weapon and weapon:HasTag("weapontag") then
			return "newsg"
		end
	end,
}
AddStategraphPostInit("wilson", function(self)
	for k, v in pairs(actionlist) do
		local oldhandlers = self.actionhandlers[k].deststate
		self.actionhandlers[k].deststate = function(inst, action)
			local oldresult = oldhandlers(inst, action)
			local newresult = v(inst, action, oldresult)
			if newresult then
				return newresult
			end
			return oldresult
		end
	end
end)
--客户端
local actionlist_client = {
	--[[[ACTIONS.ATTACK] = function(inst, act, oldresult)
		local weapon = inst.replica.combat:GetWeapon() or nil
		if weapon and weapon:HasTag("weapontag") then
			return "newsg"
		end
	end,]]
}
AddStategraphPostInit("wilson", function(self)
	for k, v in pairs(actionlist_client) do
		local oldhandlers = self.actionhandlers[k].deststate
		self.actionhandlers[k].deststate = function(inst, action)
			local oldresult = oldhandlers(inst, action)
			local newresult = v(inst, action, oldresult)
			if newresult then
				return newresult
			end
			return oldresult
		end
	end
end)
